{{- $key := "description" }}
{{- if isset site.Params.post "excerpt" }}
  {{- $key = site.Params.post.excerpt }}
{{- end }}
{{- $useDescription := and (eq $key "description") .Description }}
{{- $anchor := "" }}
{{- if default false $.Site.Params.post.readMoreFromContent }}{{ $anchor = "#post-content-body" }}{{ end }}
{{- $readMoreButton := printf "<div><a class=\"btn btn-sm btn-outline-primary btn-read-more\" href=\"%s%s\">%s</a></div>" .RelPermalink $anchor (i18n "read_more") | safeHTML }}
{{- $content :=  "" }}
{{- $readMore := true }}
{{- if $useDescription }}
  {{- $content = printf "<p>%s</p>" .Description | safeHTML }}
{{- else if strings.Contains .RawContent "<!--more-->" }}
  {{- $content = .Summary }}
  {{- $readMore = .Truncated }}
{{- else if .Params.summary }}
  {{- $content = printf "<p>%s</p>" .Params.summary | safeHTML }}
{{- else }}
  {{- $maxLength := default 320 $.Site.Params.post.excerptMaxLength }}
  {{- $ellipsis := "..." }}
  {{- if default true .Site.Params.post.plainifyExcerpt }}
    {{- $content = .Plain | htmlUnescape | truncate $maxLength $ellipsis | printf "<p>%s</p>" | safeHTML }}
  {{- else }}
    {{- $content = .Content | truncate $maxLength $ellipsis }}
  {{- end }}
  {{- if not (findRE "\\.{3}" $content) }}
    {{- $readMore = false }}
  {{- end }}
{{- end }}
{{- $content }}
{{- if $readMore }}
  {{- $readMoreButton }}
{{- end -}}
